home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / mui38dev-storm / examples / mui-demo.c < prev    next >
C/C++ Source or Header  |  1999-09-13  |  28KB  |  656 lines

  1. /*
  2. **          C Source Code For The MUI Demo Program
  3. **          --------------------------------------
  4. **
  5. **             written 1992-95 by Stefan Stuntz
  6. **
  7. ** Even if it doesn't look so, all of the code below is pure C,
  8. ** just a little bit enhanced with some MUI specific macros.
  9. **
  10. ** NOTE: This demo shows a few MUI techniques (like Return IDs)
  11. ** that are a little outdated. Be sure to also check the other
  12. ** demonstration programs for more object oriented GUI design!
  13. */
  14.  
  15. #include "demo.h"
  16.  
  17.  
  18. /*
  19. ** A little array definition:
  20. */
  21.  
  22. static const char *LVT_Brian[] =
  23. {
  24. "Cheer up, Brian. You know what they say.",
  25. "Some things in life are bad,",
  26. "They can really make you mad.",
  27. "Other things just make you swear and curse.",
  28. "When you're chewing on life's grissle,",
  29. "Don't grumble, give a whistle.",
  30. "And this'll help things turn out for the best,",
  31. "And...",
  32. "",
  33. "Always look on the bright side of life",
  34. "Always look on the light side of life",
  35. "",
  36. "If life seems jolly rotten,",
  37. "There's something you've forgotten,",
  38. "And that's to laugh, and smile, and dance, and sing.",
  39. "When you're feeling in the dumps,",
  40. "Don't be silly chumps,",
  41. "Just purse your lips and whistle, that's the thing.",
  42. "And...",
  43. "",
  44. "Always look on the bright side of life, come on!",
  45. "Always look on the right side of life",
  46. "",
  47. "For life is quite absurd,",
  48. "And death's the final word.",
  49. "You must always face the curtain with a bow.",
  50. "Forget about your sin,",
  51. "Give the audience a grin.",
  52. "Enjoy it, it's your last chance anyhow,",
  53. "So...",
  54. "",
  55. "Always look on the bright side of death",
  56. "Just before you draw your terminal breath.",
  57. "",
  58. "Life's a piece of shit,",
  59. "When you look at it.",
  60. "Life's a laugh, and death's a joke, it's true.",
  61. "You'll see it's all a show,",
  62. "Keep 'em laughing as you go,",
  63. "Just remember that the last laugh is on you.",
  64. "And...",
  65. "",
  66. "Always look on the bright side of life !",
  67. "",
  68. "...",
  69. NULL,
  70. };
  71.  
  72.  
  73.  
  74. /*
  75. ** Convetional GadTools NewMenu structure, a memory
  76. ** saving way of definig menus.
  77. */
  78.  
  79. #define ID_ABOUT  1
  80. #define ID_NEWVOL 2
  81. #define ID_NEWBRI 3
  82.  
  83. struct NewMenu Menu[] =
  84. {
  85.     { NM_TITLE, "Project"  , 0 ,0,0,(APTR)0            },
  86.     { NM_ITEM , "About..." ,"?",0,0,(APTR)ID_ABOUT     },
  87.     { NM_ITEM , NM_BARLABEL, 0 ,0,0,(APTR)0            },
  88.     { NM_ITEM , "Quit"     ,"Q",0,0,(APTR)MUIV_Application_ReturnID_Quit },
  89.     { NM_END  , NULL       , 0 ,0,0,(APTR)0            },
  90. };
  91.  
  92.  
  93. /*
  94. ** Here are all the little info texts
  95. ** that appear at the top of each demo window.
  96. */
  97.  
  98. static const char IN_Master[]    = "\tWelcome to the MUI demonstration program. \
  99. This little toy will show you how easy it is to create graphical user interfaces \
  100. with MUI and how powerful the results are.\n\tMUI is based on BOOPSI, Amiga's \
  101. basic object oriented programming system. For details about programming, see the \
  102. 'ReadMe' file and the documented source code of this demo. Only one thing so far: \
  103. it's really easy!\n\tNow go on, click around and watch this demo. Or use your \
  104. keyboard (TAB, Return, Cursor-Keys) if you like that better. Hint: play \
  105. around with the MUI preferences program and customize every pixel to fit \
  106. your personal taste.";
  107.  
  108. static const char IN_Notify[]    = "\tMUI objects communicate with each other \
  109. with the aid of a notifcation system. This system is frequently used in every \
  110. MUI application. Binding an up and a down arrow to a prop gadget e.g. makes up \
  111. a scrollbar, binding a scrollbar to a list makes up a listview. You can also \
  112. bind windows to buttons, thus the window will be opened when the button is \
  113. pressed.\n\tRemember: The main loop of this demo program simply consists of \
  114. a Wait(). Once set up, MUI handles all user actions concerning the GUI \
  115. automatically.";
  116.  
  117. static const char IN_Frames[]    = "\tEvery MUI object can have a surrounding \
  118. frame. Several types are available, all adjustable with the preferences program.";
  119.  
  120. static const char IN_Images[]    = "\tMUI offers a vector image class, that allows \
  121. images to be zoomed to any dimension. Every MUI image is transformed to match the \
  122. current screens colors before displaying.\n\tThere are several standard images for \
  123. often used GUI components (e.g. Arrows). These standard images can be defined via \
  124. the preferences program.";
  125.  
  126. static const char IN_Groups[]    = "\tGroups are very important for MUI. Their \
  127. combinations determine how the GUI will look. A group may contain any number of \
  128. child objects, which are positioned either horizontal or vertical.\n\tWhen a \
  129. group is layouted, the available space is distributed between all of its \
  130. children, depending on their minimum and maximum dimensions and on their \
  131. weight.\n\tOf course, the children of a group may be other groups. There \
  132. are no restrictions.";
  133.  
  134. /*FR* Somehow StormC couldn't handle this very line split over
  135.       several lines so I just made it one long line instead. */
  136. static const char IN_Backfill[]  = "\tEvery object can have its own background, if it wants to. MUI offers several standard backgrounds (e.g. one of the DrawInfo pens or one of the rasters below).\nThe prefs program allows defining a large number of backgrounds... try it!";
  137.  
  138. static const char IN_Listviews[] = "\tMUI's list class is very flexible. A list can \
  139. be made up of any number of columns containing formatted text or even images. Several \
  140. subclasses of list class (e.g. a directory class and a volume class) are available. \
  141. All MUI lists have the capability of multi selection, just by setting a single \
  142. flag.\n\tThe small info texts at the top of each demo window are made with floattext \
  143. class. This one just needs a character string as input and formats the text according \
  144. to its width.";
  145.  
  146. static const char IN_Cycle[]     = "\tCycle gadgets, radios buttons and simple lists \
  147. can be used to let the user pick exactly one selection from a list of choices. In this \
  148. example, all three possibilities are shown. Of course they are connected via notification, \
  149. so every object will immediately be notified and updated when necessary.";
  150.  
  151. static const char IN_String[]    = "\tOf course, MUI offers a standard string gadget class \
  152. for text input. The gadget in this example is attached to the list, you can control the \
  153. list cursor from within the gadget.";
  154.  
  155.  
  156. /*
  157. ** This are the entries for the cycle gadgets and radio buttons.
  158. */
  159.  
  160. static const char *CYA_Computer[] = { "Amiga 500","Amiga 600","Amiga 1000 :)","Amiga 1200","Amiga 2000","Amiga 3000","Amiga 4000", "Amiga 4000T", "Atari ST :(", NULL };
  161. static const char *CYA_Printer[]  = { "HP Deskjet","NEC P6","Okimate 20",NULL };
  162. static const char *CYA_Display[]  = { "A1081","NEC 3D","A2024","Eizo T660i",NULL };
  163.  
  164.  
  165. /*
  166. ** Some Macros to make my life easier and the actual source
  167. ** code more readable.
  168. */
  169.  
  170. #define List(ftxt)               ListviewObject, MUIA_Weight, 50, MUIA_Listview_Input, FALSE, MUIA_Listview_List,\
  171.                                  FloattextObject, MUIA_Frame, MUIV_Frame_ReadList, MUIA_Background, MUII_ReadListBack, MUIA_Floattext_Text, ftxt, MUIA_Floattext_TabSize, 4, MUIA_Floattext_Justify, TRUE, End, End
  172. #define DemoWindow(name,id,info) WindowObject, MUIA_Window_Title, name, MUIA_Window_ID, id, WindowContents, VGroup, Child, List(info)
  173. #define Image(nr)                ImageObject, MUIA_Image_Spec, nr, End
  174. #define ScaledImage(nr,s,x,y)    ImageObject, MUIA_Image_Spec, nr, MUIA_FixWidth, x, MUIA_FixHeight, y, MUIA_Image_FreeHoriz, TRUE, MUIA_Image_FreeVert, TRUE, MUIA_Image_State, s, End
  175. #define HProp                    PropObject, PropFrame, MUIA_Prop_Horiz, TRUE, MUIA_FixHeight, 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  176. #define VProp                    PropObject, PropFrame, MUIA_Prop_Horiz, FALSE, MUIA_FixWidth , 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  177.  
  178.  
  179. /*
  180. ** For every object we want to refer later (e.g. for notification purposes)
  181. ** we need a pointer. These pointers do not need to be static, but this
  182. ** saves stack space.
  183. */
  184.  
  185. static APTR AP_Demo;
  186. static APTR WI_Master,WI_Frames,WI_Images,WI_Notify,WI_Listviews,WI_Groups,WI_Backfill,WI_Cycle,WI_String;
  187. static APTR BT_Notify,BT_Frames,BT_Images,BT_Groups,BT_Backfill,BT_Listviews,BT_Cycle,BT_String,BT_Quit;
  188. static APTR PR_PropA,PR_PropH,PR_PropV,PR_PropL,PR_PropR,PR_PropT,PR_PropB;
  189. static APTR LV_Volumes,LV_Directory,LV_Computer,LV_Brian;
  190. static APTR CY_Computer,CY_Printer,CY_Display;
  191. static APTR MT_Computer,MT_Printer,MT_Display;
  192. static APTR ST_Brian;
  193. static APTR GA_Gauge1,GA_Gauge2,GA_Gauge3;
  194. static APTR BP_Wheel;
  195.  
  196.  
  197. /*
  198. ** This is where it all begins...
  199. */
  200.  
  201. int main(int argc,char *argv[])
  202. {
  203.  
  204. /*
  205. ** The init() functions is define in demos.h and does nothing
  206. ** but open "muimaster.library".
  207. */
  208.  
  209.     init();
  210.  
  211.  
  212. /*
  213. ** Every MUI application needs an application object
  214. ** which will hold general information and serve as
  215. ** a kind of anchor for user input, ARexx functions,
  216. ** commodities interface, etc.
  217. **
  218. ** An application may have any number of SubWindows
  219. ** which can all be created in the same call or added
  220. ** later, according to your needs.
  221. **
  222. ** Note that creating a window does not mean to
  223. ** open it, this will be done later by setting
  224. ** the windows open attribute.
  225. */
  226.  
  227.     AP_Demo = ApplicationObject,
  228.         MUIA_Application_Title         , "MUI-Demo",
  229.         MUIA_Application_Version       , "$VER: MUI-Demo 19.6 (12.02.97)",
  230.         MUIA_Application_Copyright     , "Copyright ©1992-95, Stefan Stuntz",
  231.         MUIA_Application_Author        , "Stefan Stuntz",
  232.         MUIA_Application_Description   , "Demonstrate the features of MUI.",
  233.         MUIA_Application_Base          , "MUIDEMO",
  234.         MUIA_Application_Menustrip     , MUI_MakeObject(MUIO_MenustripNM,Menu,0),
  235.  
  236.         SubWindow,
  237.             WI_String = DemoWindow("String",MAKE_ID('S','T','R','G'),IN_String),
  238.                 Child, LV_Brian = ListviewObject,
  239.                     MUIA_Listview_Input, TRUE,
  240.                     MUIA_Listview_List, ListObject, InputListFrame, End,
  241.                     End,
  242.                 Child, ST_Brian = StringObject, StringFrame, End,
  243.                 End,
  244.             End,
  245.  
  246.         SubWindow,
  247.             WI_Cycle = DemoWindow("Cycle Gadgets & RadioButtons",MAKE_ID('C','Y','C','L'),IN_Cycle),
  248.                 Child, HGroup,
  249.                     Child, MT_Computer = Radio("Computer:",CYA_Computer),
  250.                     Child, VGroup,
  251.                         Child, MT_Printer = Radio("Printer:",CYA_Printer),
  252.                         Child, VSpace(0),
  253.                         Child, MT_Display = Radio("Display:",CYA_Display),
  254.                         End,
  255.                     Child, VGroup,
  256.                         Child, ColGroup(2), GroupFrameT("Cycle Gadgets"),
  257.                             Child, KeyLabel1("Computer:",'c'), Child, CY_Computer = KeyCycle(CYA_Computer,'c'),
  258.                             Child, KeyLabel1("Printer:" ,'p'), Child, CY_Printer  = KeyCycle(CYA_Printer ,'p'),
  259.                             Child, KeyLabel1("Display:" ,'d'), Child, CY_Display  = KeyCycle(CYA_Display ,'d'),
  260.                             End,
  261.                         Child, LV_Computer =    ListviewObject,
  262.                             MUIA_Listview_Input, TRUE,
  263.                             MUIA_Listview_List, ListObject, InputListFrame, End,
  264.                             End,
  265.                         End,
  266.                     End,
  267.                 End,
  268.             End,
  269.  
  270.         SubWindow,
  271.             WI_Listviews = DemoWindow("Listviews",MAKE_ID('L','I','S','T'),IN_Listviews),
  272.                 Child, HGroup, GroupFrameT("Dir & Volume List"),
  273.                     Child, LV_Directory = ListviewObject,
  274.                         MUIA_Listview_Input, TRUE,
  275.                         MUIA_Listview_MultiSelect, TRUE,
  276.                         MUIA_Listview_List, DirlistObject, InputListFrame, MUIA_Dirlist_Directory, "ram:", MUIA_List_Title, TRUE, End,
  277.                         End,
  278.                     Child, LV_Volumes = ListviewObject,
  279.                         MUIA_Weight, 20,
  280.                         MUIA_Listview_Input, TRUE,
  281.                         MUIA_Listview_List, VolumelistObject, InputListFrame, MUIA_Dirlist_Directory, "ram:", End,
  282.                         End,
  283.                     End,
  284.                 End,
  285.             End,
  286.  
  287.         SubWindow,
  288.             WI_Notify = DemoWindow("Notifying",MAKE_ID('B','R','C','A'),IN_Notify),
  289.                 Child, HGroup, GroupFrameT("Connections"),
  290.                     Child, GA_Gauge1 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, FALSE, MUIA_FixWidth, 16, End,
  291.                     Child, PR_PropL = VProp,
  292.                     Child, PR_PropR = VProp,
  293.                     Child, VGroup,
  294.                         Child, VSpace(0),
  295.                         Child, PR_PropA = HProp,
  296.                         Child, HGroup,
  297.                             Child, PR_PropH = HProp,
  298.                             Child, PR_PropV = HProp,
  299.                             End,
  300.                         Child, VSpace(0),
  301.                         Child, VGroup, GroupSpacing(1),
  302.                             Child, GA_Gauge2 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, TRUE, End,
  303.                             Child, ScaleObject, MUIA_Scale_Horiz, TRUE, End,
  304.                             End,
  305.                         Child, VSpace(0),
  306.                         End,
  307.                     Child, PR_PropT = VProp,
  308.                     Child, PR_PropB = VProp,
  309.                     Child, GA_Gauge3 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, FALSE, MUIA_FixWidth, 16, End,
  310.                     End,
  311.                 End,
  312.             End,
  313.  
  314.         SubWindow,
  315.             WI_Backfill = DemoWindow("Backfill",MAKE_ID('B','A','C','K'),IN_Backfill),
  316.                 Child, VGroup, GroupFrameT("Standard Backgrounds"),
  317.                     Child, HGroup,
  318.                         Child, RectangleObject, TextFrame, MUIA_Background, MUII_BACKGROUND            , End,
  319.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILL                  , End,
  320.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOW                , End,
  321.                         End,
  322.                     Child, HGroup,
  323.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWBACK            , End,
  324.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWFILL            , End,
  325.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWSHINE           , End,
  326.                         End,
  327.                     Child, HGroup,
  328.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILLBACK              , End,
  329.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHINEBACK             , End,
  330.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILLSHINE             , End,
  331.                         End,
  332.                     End,
  333.                 End,
  334.             End,
  335.  
  336.         SubWindow,
  337.             WI_Groups = DemoWindow("Groups",MAKE_ID('G','R','P','S'),IN_Groups),
  338.                 Child, HGroup, GroupFrameT("Group Types"),
  339.                     Child, HGroup, GroupFrameT("Horizontal"),
  340.                         Child, RectangleObject, TextFrame, End,
  341.                         Child, RectangleObject, TextFrame, End,
  342.                         Child, RectangleObject, TextFrame, End,
  343.                         End,
  344.                     Child, VGroup, GroupFrameT("Vertical"),
  345.                         Child, RectangleObject, TextFrame, End,
  346.                         Child, RectangleObject, TextFrame, End,
  347.                         Child, RectangleObject, TextFrame, End,
  348.                         End,
  349.                     Child, ColGroup(3), GroupFrameT("Array"),
  350.                         Child, RectangleObject, TextFrame, End,
  351.                         Child, RectangleObject, TextFrame, End,
  352.                         Child, RectangleObject, TextFrame, End,
  353.                         Child, RectangleObject, TextFrame, End,
  354.                         Child, RectangleObject, TextFrame, End,
  355.                         Child, RectangleObject, TextFrame, End,
  356.                         Child, RectangleObject, TextFrame, End,
  357.                         Child, RectangleObject, TextFrame, End,
  358.                         Child, RectangleObject, TextFrame, End,
  359.                         End,
  360.                     End,
  361.                 Child, HGroup, GroupFrameT("Different Weights"),
  362.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c25 kg" ,  MUIA_Weight,  25, End,
  363.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c50 kg" ,  MUIA_Weight,  50, End,
  364.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c75 kg" ,  MUIA_Weight,  75, End,
  365.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c100 kg",  MUIA_Weight, 100, End,
  366.                     End,
  367.                 Child, HGroup, GroupFrameT("Fixed & Variable Sizes"),
  368.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  369.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cfree"  ,  MUIA_Text_SetMax, FALSE, End,
  370.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  371.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cfree"  ,  MUIA_Text_SetMax, FALSE, End,
  372.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  373.                     End,
  374.                 End,
  375.             End,
  376.  
  377.         SubWindow,
  378.             WI_Frames = DemoWindow("Frames",MAKE_ID('F','R','M','S'),IN_Frames),
  379.                 Child, ColGroup(2),
  380.                     Child, TextObject, ButtonFrame     , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cButton"     , End,
  381.                     Child, TextObject, ImageButtonFrame, InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cImageButton", End,
  382.                     Child, TextObject, TextFrame       , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cText"       , End,
  383.                     Child, TextObject, StringFrame     , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cString"     , End,
  384.                     Child, TextObject, ReadListFrame   , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cReadList"   , End,
  385.                     Child, TextObject, InputListFrame  , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cInputList"  , End,
  386.                     Child, TextObject, PropFrame       , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cProp Gadget", End,
  387.                     Child, TextObject, GroupFrame      , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cGroup"      , End,
  388.                     End,
  389.                 End,
  390.             End,
  391.  
  392.         SubWindow,
  393.             WI_Images = DemoWindow("Images",MAKE_ID('I','M','G','S'),IN_Images),
  394.                 Child, HGroup,
  395.                     Child, ColGroup(2), GroupFrameT("Some Images"),
  396.                         Child, Label("ArrowUp:"    ), Child, Image(MUII_ArrowUp    ),
  397.                         Child, Label("ArrowDown:"  ), Child, Image(MUII_ArrowDown  ),
  398.                         Child, Label("ArrowLeft:"  ), Child, Image(MUII_ArrowLeft  ),
  399.                         Child, Label("ArrowRight:" ), Child, Image(MUII_ArrowRight ),
  400.                         Child, Label("RadioButton:"), Child, Image(MUII_RadioButton),
  401.                         Child, Label("File:"       ), Child, Image(MUII_PopFile    ),
  402.                         Child, Label("HardDisk:"   ), Child, Image(MUII_HardDisk   ),
  403.                         Child, Label("Disk:"       ), Child, Image(MUII_Disk       ),
  404.                         Child, Label("Chip:"       ), Child, Image(MUII_Chip       ),
  405.                         Child, Label("Drawer:"     ), Child, Image(MUII_Drawer     ),
  406.                         End,
  407.                     Child, VGroup, GroupFrameT("Scale Engine"),
  408.                         Child, VSpace(0),
  409.                         Child, HGroup,
  410.                             Child, ScaledImage(MUII_RadioButton,1,17, 9),
  411.                             Child, ScaledImage(MUII_RadioButton,1,20,12),
  412.                             Child, ScaledImage(MUII_RadioButton,1,23,15),
  413.                             Child, ScaledImage(MUII_RadioButton,1,26,18),
  414.                             Child, ScaledImage(MUII_RadioButton,1,29,21),
  415.                             End,
  416.                         Child, VSpace(0),
  417.                         Child, HGroup,
  418.                             Child, ScaledImage(MUII_CheckMark,1,13, 7),
  419.                             Child, ScaledImage(MUII_CheckMark,1,16,10),
  420.                             Child, ScaledImage(MUII_CheckMark,1,19,13),
  421.                             Child, ScaledImage(MUII_CheckMark,1,22,16),
  422.                             Child, ScaledImage(MUII_CheckMark,1,25,19),
  423.                             Child, ScaledImage(MUII_CheckMark,1,28,22),
  424.                             End,
  425.                         Child, VSpace(0),
  426.                         Child, HGroup,
  427.                             Child, ScaledImage(MUII_PopFile,0,12,10),
  428.                             Child, ScaledImage(MUII_PopFile,0,15,13),
  429.                             Child, ScaledImage(MUII_PopFile,0,18,16),
  430.                             Child, ScaledImage(MUII_PopFile,0,21,19),
  431.                             Child, ScaledImage(MUII_PopFile,0,24,22),
  432.                             Child, ScaledImage(MUII_PopFile,0,27,25),
  433.                             End,
  434.                         Child, VSpace(0),
  435.                         End,
  436.                     End,
  437.                 End,
  438.             End,
  439.  
  440.         SubWindow,
  441.             WI_Master = WindowObject,
  442.             MUIA_Window_Title, "MUI-Demo",
  443.             MUIA_Window_ID   , MAKE_ID('M','A','I','N'),
  444.             WindowContents, VGroup,
  445.                 Child, TextObject, GroupFrame, MUIA_Background, MUII_SHADOWFILL, MUIA_Text_Contents, "\33c\0338MUI - \33bM\33nagic\33bU\33nser\33bI\33nnterface\nwritten 1992-95 by Stefan Stuntz",  End,
  446.  
  447.                 Child, List(IN_Master),
  448.  
  449.                 Child, VGroup, GroupFrameT("Available Demos"),
  450.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  451.                         Child, BT_Groups    = SimpleButton("_Groups"),
  452.                         Child, BT_Frames    = SimpleButton("_Frames"),
  453.                         Child, BT_Backfill  = SimpleButton("_Backfill"),
  454.                         End,
  455.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  456.                         Child, BT_Notify    = SimpleButton("_Notify"),
  457.                         Child, BT_Listviews = SimpleButton("_Listviews"),
  458.                         Child, BT_Cycle     = SimpleButton("_Cycle"),
  459.                         End,
  460.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  461.                         Child, BT_Images    = SimpleButton("_Images" ),
  462.                         Child, BT_String    = SimpleButton("_Strings"),
  463.                         Child, BT_Quit      = SimpleButton("_Quit"   ),
  464.                         End,
  465.                     End,
  466.                 End,
  467.             End,
  468.  
  469.         End;
  470.  
  471.  
  472. /*
  473. ** See if the application was created. The fail function
  474. ** is defined in demos.h, it deletes every created object
  475. ** and closes "muimaster.library".
  476. **
  477. ** Note that we do not need any
  478. ** error control for the sub objects since every error
  479. ** will automatically be forwarded to the parent object
  480. ** and cause this one to fail too.
  481. */
  482.  
  483.     if (!AP_Demo) fail(AP_Demo,"Failed to create application.");
  484.  
  485.  
  486.  
  487. /*
  488. ** Here comes the notifcation magic. Notifying means:
  489. ** When an attribute of an object changes, then please change
  490. ** another attribute of another object (accordingly) or send
  491. ** a method to another object.
  492. */
  493.  
  494. /*
  495. ** Lets bind the sub windows to the corresponding button
  496. ** of the master window.
  497. */
  498.  
  499.     DoMethod(BT_Frames   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Frames   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  500.     DoMethod(BT_Images   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Images   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  501.     DoMethod(BT_Notify   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Notify   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  502.     DoMethod(BT_Listviews,MUIM_Notify,MUIA_Pressed,FALSE,WI_Listviews,3,MUIM_Set,MUIA_Window_Open,TRUE);
  503.     DoMethod(BT_Groups   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Groups   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  504.     DoMethod(BT_Backfill ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Backfill ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  505.     DoMethod(BT_Cycle    ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Cycle    ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  506.     DoMethod(BT_String   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_String   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  507.  
  508.     DoMethod(BT_Quit     ,MUIM_Notify,MUIA_Pressed,FALSE,AP_Demo,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  509.  
  510.  
  511. /*
  512. ** Automagically remove a window when the user hits the close gadget.
  513. */
  514.  
  515.     DoMethod(WI_Images   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Images   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  516.     DoMethod(WI_Frames   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Frames   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  517.     DoMethod(WI_Notify   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Notify   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  518.     DoMethod(WI_Listviews,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Listviews,3,MUIM_Set,MUIA_Window_Open,FALSE);
  519.     DoMethod(WI_Groups   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Groups   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  520.     DoMethod(WI_Backfill ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Backfill ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  521.     DoMethod(WI_Cycle    ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Cycle    ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  522.     DoMethod(WI_String   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_String   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  523.  
  524.  
  525. /*
  526. ** Closing the master window forces a complete shutdown of the application.
  527. */
  528.  
  529.     DoMethod(WI_Master,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,AP_Demo,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  530.  
  531.  
  532. /*
  533. ** This connects the prop gadgets in the notification demo window.
  534. */
  535.  
  536.     DoMethod(PR_PropA,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropH,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  537.     DoMethod(PR_PropA,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropV,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  538.     DoMethod(PR_PropH,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropL,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  539.     DoMethod(PR_PropH,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropR,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  540.     DoMethod(PR_PropV,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropT,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  541.     DoMethod(PR_PropV,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropB,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  542.  
  543.     DoMethod(PR_PropA ,MUIM_Notify,MUIA_Prop_First   ,MUIV_EveryTime,GA_Gauge2,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  544.     DoMethod(GA_Gauge2,MUIM_Notify,MUIA_Gauge_Current,MUIV_EveryTime,GA_Gauge1,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  545.     DoMethod(GA_Gauge2,MUIM_Notify,MUIA_Gauge_Current,MUIV_EveryTime,GA_Gauge3,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  546.  
  547.  
  548. /*
  549. ** And here we connect cycle gadgets, radio buttons and the list in the
  550. ** cycle & radio window.
  551. */
  552.  
  553.     DoMethod(CY_Computer,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Computer,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  554.     DoMethod(CY_Printer ,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Printer ,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  555.     DoMethod(CY_Display ,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Display ,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  556.     DoMethod(MT_Computer,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Computer,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  557.     DoMethod(MT_Printer ,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Printer ,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  558.     DoMethod(MT_Display ,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Display ,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  559.     DoMethod(MT_Computer,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,LV_Computer,3,MUIM_Set,MUIA_List_Active ,MUIV_TriggerValue);
  560.     DoMethod(LV_Computer,MUIM_Notify,MUIA_List_Active ,MUIV_EveryTime,MT_Computer,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  561.  
  562.  
  563. /*
  564. ** This one makes us receive input ids from several list views.
  565. */
  566.  
  567.     DoMethod(LV_Volumes ,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,AP_Demo,2,MUIM_Application_ReturnID,ID_NEWVOL);
  568.     DoMethod(LV_Brian   ,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,AP_Demo,2,MUIM_Application_ReturnID,ID_NEWBRI);
  569.  
  570.  
  571. /*
  572. ** Now lets set the TAB cycle chain for some of our windows.
  573. */
  574.  
  575.     DoMethod(WI_Master   ,MUIM_Window_SetCycleChain,BT_Groups,BT_Frames,BT_Backfill,BT_Notify,BT_Listviews,BT_Cycle,BT_Images,BT_String,NULL);
  576.     DoMethod(WI_Listviews,MUIM_Window_SetCycleChain,LV_Directory,LV_Volumes,NULL);
  577.     DoMethod(WI_Cycle    ,MUIM_Window_SetCycleChain,MT_Computer,MT_Printer,MT_Display,CY_Computer,CY_Printer,CY_Display,LV_Computer,NULL);
  578.     DoMethod(WI_String   ,MUIM_Window_SetCycleChain,ST_Brian,NULL);
  579.  
  580.  
  581. /*
  582. ** Set some start values for certain objects.
  583. */
  584.  
  585.     DoMethod(LV_Computer,MUIM_List_Insert,CYA_Computer,-1,MUIV_List_Insert_Bottom);
  586.     DoMethod(LV_Brian   ,MUIM_List_Insert,LVT_Brian,-1,MUIV_List_Insert_Bottom);
  587.     set(LV_Computer,MUIA_List_Active,0);
  588.     set(LV_Brian   ,MUIA_List_Active,0);
  589.     set(ST_Brian   ,MUIA_String_AttachedList,LV_Brian);
  590.  
  591.  
  592. /*
  593. ** Everything's ready, lets launch the application. We will
  594. ** open the master window now.
  595. */
  596.  
  597.     set(WI_Master,MUIA_Window_Open,TRUE);
  598.  
  599.  
  600. /*
  601. ** This is the main loop. As you can see, it does just nothing.
  602. ** Everything is handled by MUI, no work for the programmer.
  603. **
  604. ** The only thing we do here is to react on a double click
  605. ** in the volume list (which causes an ID_NEWVOL) by setting
  606. ** a new directory name for the directory list. If you want
  607. ** to see a real file requester with MUI, wait for the
  608. ** next release of MFR :-)
  609. */
  610.  
  611.     {
  612.         ULONG signal;
  613.         BOOL running = TRUE;
  614.         char *buf;
  615.  
  616.         while (running)
  617.         {
  618.             switch (DoMethod(AP_Demo,MUIM_Application_Input,&signal))
  619.             {
  620.                 case MUIV_Application_ReturnID_Quit:
  621.                     running = FALSE;
  622.                     break;
  623.  
  624.                 case ID_NEWVOL:
  625.                     DoMethod(LV_Volumes,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&buf);
  626.                     set(LV_Directory,MUIA_Dirlist_Directory,buf);
  627.                     break;
  628.  
  629.                 case ID_NEWBRI:
  630.                     get(LV_Brian,MUIA_List_Active,&buf);
  631.                     set(ST_Brian,MUIA_String_Contents,LVT_Brian[(int)buf]);
  632.                     break;
  633.  
  634.                 case ID_ABOUT:
  635.                     MUI_Request(AP_Demo, WI_Master, 0, NULL, "OK", "MUI-Demo\n© 1992-95 by Stefan Stuntz");
  636.                     break;
  637.             }
  638.             if (running && signal) Wait(signal);
  639.         }
  640.     }
  641.  
  642.  
  643.  
  644. /*
  645. ** Call the fail function in demos.h, this will dispose the
  646. ** application object and close "muimaster.library".
  647. */
  648.  
  649.     fail(AP_Demo,NULL);
  650. }
  651.  
  652.  
  653. /*
  654. ** This is the end...
  655. */
  656.